<template>
    <div v-show="showDialog">
        <div class="add-address-show1">
            <div class="title">
                <div>审批人选择</div>
                <img :src="$global.Image.icon_close" @click="_cancelDialog" />
            </div>
            <div class="add-input">
                <ul class="ul" v-if="approveList.length">
                    <li class="li td-fsc a" :class="item.checked?'select':''" v-for="(item, idx) in approveList" :key="idx" @click="_selectApprove(idx)">
                        <img class="icon-checked" :src=" item.checked ? $global.Image.icon_checked : $global.Image.icon_checked_grey" />
                        <div class="detail">{{item.username}}</div>
                        <div class="name">{{item.phone}}</div>
                    </li>
                    <div class="addAddr" @click="_confirmDialog">提交</div>
                </ul>
                <div class="nodata" v-else>
                    <img :src="$global.Image.noData" />
                </div>
            </div>
        </div>
        <div class="dialog-shade"></div>
    </div>
</template>

<script>
import { getApproveList } from "@api/user";

export default {
    name: "orderName",
    props: ["approveType"],
    data() {
        return {
            showDialog: false,
            approveList: [],
            approveInfo: {},
            callback: null,
        };
    },
    mounted () {
        this.getApprove()
    },
    methods: {
        // 获取审核人列表
        getApprove() {
            getApproveList().then((res) => {
                let approveList = res.data;
                approveList.forEach((item) => {
                    if (item.is_default) {
                        item.checked = true;
                        this.approveInfo = item;
                    } else {
                        item.checked = false;
                    }
                });
                this.approveList = approveList;
            });
        },
        // 选择审核人
        _selectApprove(index) {
            this.approveList.map((item) => {
                item.checked = false;
            });
            this.approveList[index].checked = true;
            this.approveInfo = this.approveList[index];
            this.$forceUpdate();
        },
        /**
         * 显示
         */
        showSelectDialog(callback) {
            this.callback = callback;
            this.showDialog = true;
        },
        // 关闭
        _cancelDialog() {
            this.showDialog = false;
        },
        // 确认
        _confirmDialog () {
            this.callback({uid: this.approveInfo.uid})
            this.showDialog = false;
        }
    }
};
</script>
<style >
.el-input {
    width: 100%;
}
.add-address-show .rule-form {
    width: auto;
}
</style>
<style scoped  rel="stylesheet/scss" lang="scss">
$color: #da213d;
.for-itm {
    margin-left: -50px;
    margin-top: 50px;
    .el-form-item__content {
        margin-left: 0 !important;
        width: 540px;
        display: flex;
        justify-content: space-between;
        .btn-r {
            width: 240px;
            height: 44px;
            background: #da213d;
            font-size: 16px;
            border-radius: 5px;
        }
        .btn-b {
            width: 242px;
            height: 46px;
            border: 1px solid #da213d !important;
            border-radius: 5px;
            font-size: 16px;
            color: #da213d !important;
            background: #fff !important;
        }
    }
}
.add-address-show1 {
    position: fixed;
    left: 50%;
    right: 0;
    top: 50%;
    transform: translate(-50%,-50%);
    width: 700px;
    border-radius: 4px;
    background-color: rgba(255, 255, 255, 1);
    box-shadow: 0 0 15px 4px rgba(0, 0, 0, 0.2);
    z-index: 20;
    .title {
        display: flex;
        width: 100%;
        height: 67px;
        align-items: center;
        background: #fbf0f0;
        justify-content: center;
        > div:nth-of-type(1) {
            font-size: 21px;
            color: #da213d;
            font-weight: bold;
        }
        img {
            display: block;
            width: 20px;
            height: 20px;
            font-size: 30px;
            color: #999999;
            position: absolute;
            right: 32px;
            cursor: pointer;
        }
    }
    .add-input {
        display: flex;
        justify-content: center;
        flex-direction: column;
        align-items: center;
        padding: 60px 0;
        background: #fff;
    }
    .rule-form {
        width: 460px;
        button {
            width: 140px;
        }
    }
}

.dialog-shade {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 18;
    background-color: rgba($color: #000000, $alpha: 0.4);
}

.el-cascader {
    display: block;
    position: absolute;
    top: 0;
    width: 100%;
    opacity: 0;
}
::-webkit-scrollbar{
    width: 0;
    height: 0;
    opacity: 0;
}
ul {
    width: 100%;
    // border: 1px solid #dbdbdb;
    height: 380px;
    margin-bottom: 20px;
    overflow-y: scroll;
    .addAddr {
        width: 346px;
height: 44px;
background: #da213d;
border-radius: 5px;
font-size: 16px;
text-align: center;
color: #ffffff;
line-height: 44px;
margin-top: 37px;
margin-right: auto;
margin-left: auto;
cursor: pointer;
    }
    .li {

        background: #ffffff;
        border: 1px solid #eaa090;
        border-radius: 5px;
        height: 60px;
        margin: 0 40px 20px;
        font-size: 16px;
        padding: 0 20px;
        box-sizing: border-box;
        color: #333;
        .li-info-name {
            margin: 0 55px 0 30px;
            font-size: 18px;
            width: 90px;
            font-weight: bold;
            color: #da213d;
            line-height: 46px;
        }
        .name {
            text-align: right;
            flex: 1;
        }
        div {
            margin-left: 20px;
        }
        img {
            display: block;
            width: 20px;
            height: 20px;
        }
        .edit-box {
            // display: none;
            justify-content: flex-end;
            flex: 1;
            margin-right: 8px;
            img {
                width: 16px;
                height: 16px;
                margin-right: 5px;
            }
            .span1 {
                font-size: 18px;
                font-weight: bold;
                color: #fa321b;
                margin-right: 30px;
            }
            .span2 {
                font-size: 18px;
                font-weight: bold;
                color: #3ca9d7;
                margin-right: 30px;
            }
            .span3 {
                font-size: 14px;
                color: #014a97;
                margin-right: 30px;
            }
        }
    }
    li:hover .edit-box {
        display: flex;
    }
    li.select {
        color: #333333;
        font-weight: bold;
        background: #fbf7f7;
        border: 1px solid #eaa090;
    }
}
</style>